package lincen.javame.game.handhelddevice;

import java.awt.Graphics;



/**
 * 掌上游戏机画布
 * 此游戏画布就是7,8十年代青年们玩的那款游戏机的画布,
 * 画布上面:
 * 	左部分:有N个黑色方块,拼成一块屏幕,
 * 	右部份:得分信息, 等级信息, 以及一个4x4的方块, 用于显示在俄罗斯方块游戏中,下一个将要出现的方块
 * @author 林岑
 */
public class HandHeldGraphics {

	/**
	 * 信息区
	 */
	private Infomation infomation;
	
	/**
	 * 点阵
	 */
	private Cells cells;
	
	/**
	 * 创建一个方块横向数量为width, 纵向数量为height的点阵画布
	 * @param nW
	 * @param nH
	 */
	public HandHeldGraphics(int nW, int nH, int screenW, int screenH) {
		this.infomation = new Infomation();
		this.infomation.setSize(Cells.CELLWIDTH * 6, Cells.CELLWIDTH * nH);
		this.cells = new Cells(nW, nH);
		this.cells.setX(screenW / 2 - (this.cells.getWidth() + this.infomation.getWidth()) / 2);
		this.cells.setY(screenH / 2 - this.cells.getHeight() / 2);
		this.infomation.setLocation(this.cells.getX() + this.cells.getWidth(), this.cells.getY());
	}

	/**
	 * 绘制
	 * @param g
	 */
	public void paint(Graphics g) {
		this.cells.paint(g);
		this.infomation.paint(g);
	}
	
	public void open(int x, int y) {
		this.cells.open(x, y);
	}
	
	/**
	 * 关闭某个点
	 * @param x
	 * @param y
	 */
	public void close(int x, int y) {
		this.cells.close(x, y);
	}

	public void clear() {
		this.cells.clear();
	}
	
	public void setLevel(int level) {
		this.infomation.setLevel(level);
	}
	
	public void setScore(int score) {
		this.infomation.setScore(score);
	}

	/**
	 * 打开NextPoint的点x, y
	 * @param x
	 * @param y
	 */
	public void openNextPoint(int x, int y) {
		this.infomation.open(x, y);
	}

	/**
	 * 关闭NextPoint的点x, y
	 * @param x
	 * @param y
	 */
	public void closeNextPoint(int x, int y) {
		this.infomation.close(x, y);
	}
}
